package com.atguigu.com.seckill.controller;

import com.atguigu.com.seckill.service.SeckillService;
import com.atguigu.com.seckill.to.SeckillSkuRedisTo;
import com.atguigu.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SeckillConteoller {


    @Autowired
    SeckillService seckillService;

    /**
     * 获取秒杀商品信息
     * @return
     */
    @GetMapping("/getSeckill")
    public R getSeckill(){
        List<SeckillSkuRedisTo> seckill = seckillService.getSeckill();
        return R.ok().setData(seckill);
    }

    /**
     * 秒杀
     */
    @GetMapping("/kill")
    public String kill(@RequestParam("killId")String killId,
                       @RequestParam("code")String code,
                       @RequestParam("num")Integer num){
        String s = seckillService.kill(killId,code,num);
        return null;
    }
}
